package com.bodacn.keypoint.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bodacn.keypoint.R;
import com.bodacn.keypoint.bean.BadTypeBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


public class QuestionGridAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<BadTypeBean> list;

    public QuestionGridAdapter(List<BadTypeBean> list, Context context) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.list = list;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.question_gr_item, parent, false);
            viewHodler=new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        viewHodler.itemPO.setText(list.get(position).getQuestionName());
        viewHodler.itemNum.setText(list.get(position).getNum()+"");

        return convertView;
    }




    class ViewHolder {
        @BindView(R.id.item_PO)
        TextView itemPO;
        @BindView(R.id.item_num)
        TextView itemNum;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
